JMU JMU - Department of Computer Science
Help Tools
C/C++ Programming Style Guide


1 Course Style Requirements

Your code must conform to the Google C++ Style Guide with the following exceptions/additions:
  • Files must be named name.type.

    Specification files (i.e., header files) must have a type of .h, implementation files must have a type of .cpp, and template files (which must contain both the specification and the implementation) must have a type of .hpp.

  • Comments must be in Doxygen format.

    The Javadoc format is preferred, but not required.

  • Most comments should be in the file containing the specification (i.e., the .h or .hpp file.

    Only detailed comments about the implementation should be in the implementation file (i.e., the .cpp file).

  • Class comments must include your name and must attest to your compliance with the JMU Honor Code.

    Include a statement like This work complies with the JMU Honor Code.

2 Other Style Guides

Different people have different opinions about what is "stylish". If you are interested in such things (and you should be) you might want to take a look at:

There are also several books devoted to C/C++ style, including:

Cargill, T. (1992) C++ Programming Style, Addison-Wesley , Reading, MA.
(Order from amazon , order from Barnes and Noble , compare at bigwords , compare at CampusBooks4Less , order from Chegg , or search eFollett )

Coplien, J.O. (1991) Advanced C++ Programming Styles and Idioms, Addison-Wesley , Reading, MA.
(Order from amazon , order from Barnes and Noble , compare at bigwords , compare at CampusBooks4Less , order from Chegg , or search eFollett )

Ranade, J. and A. Nash (1992) The Elements of C Programming Style, McGraw Hill , Boston.
(Order from amazon , order from Barnes and Noble , compare at bigwords , compare at CampusBooks4Less , order from Chegg , or search eFollett )

3 Style Humor

As mentioned above, different people have different opinions about what is "stylish". This leads to many fights (and some jokes).

../lectures/comics/Hackles-Style.png
(Courtesy of Hackles)

http://imgs.xkcd.com/comics/code_quality.png
(Courtesy of xkcd)

http://imgs.xkcd.com/comics/code_quality_2.png
(Courtesy of xkcd)

Copyright 2019